package com.beardedcoder.lowPower.model;

import java.util.Calendar;

/**
 * Represents information on the state of battery on a mobile device at a particular point in time.
 * @author bilbovb
 *
 */
public final class BatteryData
{
	private long id;
	private int health;
	private int powerSource;
	private int status;
	private int powerLevel;
	private int voltage;
	private float temperature;
	private String technology;
	private int charging;
	private Calendar occurred;
	
	public BatteryData(int health, int powerSource, int status, int powerLevel, int voltage, float temperature, 
			String technology, int charging)
	{
		this.health = health;
		this.powerSource = powerSource;
		this.status = status;
		this.powerLevel = powerLevel;
		this.voltage = voltage;
		this.temperature = temperature;
		this.technology = technology;
		this.charging = charging;
		this.occurred = Calendar.getInstance();
	}
	
	public long getId()
	{
		return id;
	}
	
	public void setId(long id)
	{
		this.id = id;
	}

	public int getHealth()
	{
		return health;
	}

	public int getPowerSource()
	{
		return powerSource;
	}

	public int getStatus()
	{
		return status;
	}

	public int getPowerLevel()
	{
		return powerLevel;
	}

	public int getVoltage()
	{
		return voltage;
	}

	public float getTemperature()
	{
		return temperature;
	}

	public String getTechnology()
	{
		return technology;
	}

	public int getCharging()
	{
		return charging;
	}
	
	public Calendar getOccurred()
	{
		return occurred;
	}

	@Override
	public int hashCode()
	{
		final int prime = 31;
		int result = 1;
		result = prime * result + powerLevel;
		result = prime * result + powerSource;
		return result;
	}

	/**
	 * The only fields that we rely on for equals with this domain object are powerLevel and powerSource.
	 * The rest are ignored.
	 */
	@Override
	public boolean equals(Object obj)
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		BatteryData other = (BatteryData) obj;
		if (powerLevel != other.getPowerLevel())
			return false;
		if (powerSource != other.getPowerSource())
			return false;
		return true;
	}
	
	
}
